/*
 * @Author: liruo liruo_hrh@163.com
 * @Date: 2022-11-27 13:34:47
 * @LastEditors: liruo liruo_hrh@163.com
 * @LastEditTime: 2022-11-27 13:35:09
 * @FilePath: \dahua-data-struct\me\tree\main..cpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include <iostream>
#include <vector>
#include <algorithm>
#include "BSTree.hpp"
#include "HFMTree.hpp"
using namespace std;
BSTree<int>& buildBinarySearchTree(){
    BSTree<int> *bsTree = new BSTree<int>();
    //pre 10 7 4 2 1 9 16 13 11 19
    //in [1 2 4 7 9 10 11 13 16 19 ]
    //post [1 2 4 9 7 11 13 19 16 10 ]
    int preBuild[] = {10,16,7,13,4,19,9,11,2,1};
    for (int i = 0; i < 10; ++i) {
        bsTree->add(preBuild[i]);
    }
    return *bsTree;
}
int main()
{
    string content = "you is a good man";
    string encodeContent = HFMTree::encodeByHFMCode(content);
    string binaryContent = HFMTree::bytesToBinaryStr(content);
    cout<<"content len:\t"<<binaryContent.length()<<endl;
    cout<<"encodeContent len:\t"<<encodeContent.length()<<endl;
    cout<<"compressibility:\t"<<1.0 * (binaryContent.length() - encodeContent.length()) / binaryContent.length() * 100<<"%"<<endl;

    string decodeContent = HFMTree::decodeByHFMCode(encodeContent,HFMTree::encodeHfmCodeMap);
    cout<<"content:\t"<<content<<endl;
    cout<<"decodeContent:\t"<<decodeContent<<endl;
//    BSTree<int> bsTree = buildBinarySearchTree();
//    bsTree.traverse_pre_recursion();
//    bsTree.traverse_pre_stack();
//    bsTree.traverse_in_recursion();
//    bsTree.traverse_in_stack();
//    bsTree.traverse_post_recursion();
//    bsTree.traverse_post_stack();
}